package com.smz.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.smz.entity.TWarning;
import com.smz.service.TWarningService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class TWarningController {


    @Autowired
    private TWarningService tWarningService;

    @RequestMapping(value = "/tWarning",method = RequestMethod.GET)
    public ResponseEntity<List<TWarning>> findTWarning(@RequestParam("tMenuNo") String tMenuNo,@RequestParam("tProductId")String tProductId,@RequestParam("tProductName")String tProductName){
        List<TWarning> listTWarning = tWarningService.findTWarningByTMenuNoGgy("".equals(tMenuNo)?null:Integer.valueOf(tMenuNo),"".equals(tProductId)?null:Integer.valueOf(tProductId),"".equals(tProductName)?null:tProductName);
        return ResponseEntity.ok(listTWarning);
    }

    @RequestMapping(value = "/tWarning",method = RequestMethod.PUT)
    public String modifyTWarning(@RequestBody TWarning tWarning){
        tWarningService.update(tWarning,new QueryWrapper<TWarning>().lambda().eq(TWarning::getProductId,tWarning.getProductId()));
        return "ok";
    }
}
